#!/bin/sh -efu

gear_rules_copy_glob_sub_common()
{
	local spec=file.spec
	local n=foo
	local v=1
	local r=2
	local dir=a
	local name=file
	local rule; rule="$1"; shift

	printf 'Name:%s\nVersion: %s\nRelease:	%s' "$n" "$v" "$r" >"$spec"
	mkdir -p $dir/b$name
	touch $dir/b$name/$name
	echo "test $gear_directive" >$dir/$name
	mkdir .gear
	printf '%s\n' "$rule" >.gear/rules
	git add $spec $dir .gear
	git commit -q -a -m 1

	finalize_repo

	$GEAR "$GEAR_OUT"
	check_pkgtar_list "$spec
./
./$spec
./$name$compress_suffix"
	check_pkgtar_spec "$GEAR_OUT" "$spec"
	unpack_pkgtar_to .out
	result="$($decompress_prog ".out/$name$compress_suffix")"
	assertEquals "test $gear_directive" "$result"
}

gear_rules_copy_glob_sub() # test entry point
{
	gear_rules_copy_glob_sub_common "$gear_directive: a/*"
}

gear_rules_copy_compress_glob_sub() # test entry point
{
	gear_rules_copy_glob_sub_common "compress: type=$gear_directive -- a/*"
}
